]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Correct idleness
authorJasper St. Pierre <jstpierre@mecheye.net>
Fri, 10 Aug 2012 21:54:33 +0000 (18:54 -0300)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 20 Aug 2012 01:15:47 +0000 (21:15 -0400)
If the user is already active when the notification pops up, we
won't get an idle watcher because there's no transition from
active to idle or vice versa. Correct this by initializing the
state correctly from XSync.

js/ui/messageTray.js
src/shell-idle-monitor.c
src/shell-idle-monitor.h

index 5ba08306a2c3c52c2fc3d87f3f1c8b679f74d127..8b420a6afc5497a816782cfd80710ef08e9120fd 100644 (file)
@@ -39,6 +39,8 @@ const NOTIFICATION_ICON_SIZE = 24;
 // range from the point where it left the tray.
 const MOUSE_LEFT_ACTOR_THRESHOLD = 20;
 
+const IDLE_TIME = 1000;
+
 const State = {
     HIDDEN:  0,
     SHOWING: 1,
@@ -1979,9 +1981,9 @@ const MessageTray = new Lang.Class({
 
     _showNotification: function(notification) {
         this._notification = notification;
-        this._userActiveWhileNotificationShown = false;
-        this._idleMonitorWatchId = this.idleMonitor.add_watch(1000,
-                                                                  Lang.bind(this, this._onIdleMonitorWatch));
+        this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME;
+        this._idleMonitorWatchId = this.idleMonitor.add_watch(IDLE_TIME,
+                                                              Lang.bind(this, this._onIdleMonitorWatch));
         this._notificationClickedId = this._notification.connect('done-displaying',
                                                                  Lang.bind(this, this._escapeTray));
         this._notificationBin.child = this._notification.actor;
index 592f4772c177e3bcacd5a19e193cf7fdca8e42db..5bdb6ba2c854ac634e5325ba830087387aa1bb21 100644 (file)
@@ -416,3 +416,14 @@ shell_idle_monitor_remove_watch (ShellIdleMonitor *monitor,
         g_hash_table_remove (monitor->priv->watches,
                              GUINT_TO_POINTER (id));
 }
+
+gint64
+shell_idle_monitor_get_idletime (ShellIdleMonitor *monitor)
+{
+        XSyncValue value;
+
+        if (!XSyncQueryCounter (monitor->priv->display, monitor->priv->counter, &value))
+                return FALSE;
+
+        return _xsyncvalue_to_int64 (value);
+}
index 2fcd0820b432937217baaed967ae22201a4c23e6..6a620827fc62a4c5058171e424399355993ffd6a 100644 (file)
@@ -67,6 +67,8 @@ guint              shell_idle_monitor_add_watch    (ShellIdleMonitor         *mo
 void               shell_idle_monitor_remove_watch (ShellIdleMonitor         *monitor,
                                                     guint                     id);
 
+gint64             shell_idle_monitor_get_idletime (ShellIdleMonitor         *monitor);
+
 G_END_DECLS
 
 #endif /* __SHELL_IDLE_MONITOR_H */